package com.lsk.util;

import com.jfinal.plugin.activerecord.Record;
import org.apache.commons.collections.FastHashMap;

import java.util.List;
import java.util.Map;

/**
 * Record 转为Map 移除非空
 * Created by Administrator on 2017/10/23 0023.
 */
public class RecordToMap {
    public static Map getNotNull(Record record){
        String jsonStr=record.toJson();
        Map<String, Object> map=JsonUtil.getMapFromJsonObjStr(jsonStr);
        Map<String, Object> tempMap=new FastHashMap();
                 for (Map.Entry entry : map.entrySet()) {
                          if (entry.getValue()==null || "null".equals(entry.getValue()+"")){
                              tempMap.put(entry.getKey().toString(),"");
                          }else {
                              tempMap.put(entry.getKey().toString(),entry.getValue()+"");
                          }
                     }
        return tempMap;
    }

}
